package org.zqy.action;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.util.ServletContextAware;
import org.zqy.service.impl.ArticleServiceImpl;
import org.zqy.service.impl.UserServiceImpl;

import com.opensymphony.xwork2.ActionSupport;

/**
 * 所有action的基类，提供HttpServletRequest、ServletContext、HttpServletResponse
 * 
 * @author ZQY
 * 
 */
public class BaseAction extends ActionSupport implements ServletRequestAware,
		ServletResponseAware, ServletContextAware {

	private static final long serialVersionUID = 1L;

	private ArticleServiceImpl contentServiceImpl;
	private UserServiceImpl userServiceImpl;
	private HttpServletRequest request;
	private ServletContext servletContext;
	private HttpServletResponse response;

	public HttpServletRequest getRequest() {
		return request;
	}

	public ServletContext getServletContext() {
		return servletContext;
	}

	public HttpServletResponse getResponse() {
		return response;
	}

	// 默认执行成功
	@Override
	public String execute() {
		return SUCCESS;
	}

	@Override
	public void setServletContext(ServletContext ser) {
		this.servletContext = ser;

	}

	@Override
	public void setServletResponse(HttpServletResponse res) {
		this.response = res;

	}

	@Override
	public void setServletRequest(HttpServletRequest req) {
		this.request = req;

	}

	public ArticleServiceImpl getContentServiceImpl() {
		return contentServiceImpl;
	}

	public void setContentServiceImpl(ArticleServiceImpl contentServiceImpl) {
		this.contentServiceImpl = contentServiceImpl;
	}

	public UserServiceImpl getUserServiceImpl() {
		return userServiceImpl;
	}

	public void setUserServiceImpl(UserServiceImpl userServiceImpl) {
		this.userServiceImpl = userServiceImpl;
	}
}
